<?php

namespace App\Dao;

use App\Model\SettingsModel;

class SettingsDao extends BaseDao
{
    public static function builder_query($params = []): \Illuminate\Database\Eloquent\Builder
    {
        $query = SettingsModel::query();
        $query->when(checkIsHasField($params,'id'),function ($query)use ($params){
            $query->where('id',$params['id']);
        });

        $query->when(checkIsHasField($params,'key_name'),function ($query)use ($params){
            $query->where('key_name',$params['key_name']);
        });

        return $query;
    }


    public static function get_set_value($key_name = ''){
        return self::builder_query([
            'key_name'=>$key_name
        ])->value('key_text');
    }
}
